Skip to content

NO3 runoff: keep the mixing-zone fraction of the layer straddling depth_runoff_Nloss - #4355

Open
wwieder wants to merge 1 commit into
ESCOMP:masterfrom
wwieder:fix-no3-runoff-partial-layer
Open

wwieder wants to merge 1 commit into
ESCOMP:masterfrom
wwieder:fix-no3-runoff-partial-layer

Conversation

@wwieder

@wwieder wwieder commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

This PR makes NO3 runoff calculations consistent with surface water runoff calculations.

Description of changes

In SoilBiogeochemNLeaching, NO3 runoff loss from the soil layer that straddles depth_runoff_Nloss (5 cm) was calculated as if the whole layer were inside the mixing zone. The included fraction f = (D − z_{j−1})/dz was multiplied in and then cancelled by dividing by (D − z_{j−1}). surface_water, by contrast, counts only fraction f of that layer's water. On the default 20SL_8.5m grid (layer 2 spans 0.02–0.06 m, f = 0.75), total NO3 runoff loss is about 20% too high. The formula has been unchanged since clm4_0_60 (2013). Details and history are in #4353.

This PR changes only src/soilbiogeochem/SoilBiogeochemNLeachingMod.F90: the straddling-layer flux now divides by the full layer thickness col%dz(c,j) instead of (depth_runoff_Nloss − zisoi(j−1)). The layer then loses sf_no3·NO3·f·q_surf/W_mix per unit volume, consistent with surface_water, and the water-weight shares across layers sum to 1.

Status: tested; see the test results.

Specific notes

Contributors other than yourself, if any:

  • Bug found by the CTSM correctness audit (finding SBGC-001); fix drafted with AI assistance (Claude).

CTSM issues resolved or otherwise addressed, if any:

If answers are expected to change, describe (delete this line otherwise):

  • Answer-changing for all BGC, BGC-Crop and FATES runs with use_nitrif_denitrif (the default) that have surface runoff. SMIN_NO3_RUNOFF should decrease by about 15–20%. Because runoff N leaves the column, soil mineral N and downstream N cycling change slightly as well. This is not a diagnostic-only change.

Any user interface changes (namelist or namelist defaults changes)?

  • No.

Testing planned or performed, if any:

  • ERP_D_Ld5.f10_f10_mg37.I1850Clm60BgcCrop.derecho_intel.clm-nvmovement--clm-matrixcnOn
  • ERI_C2_Ld9.f10_f10_mg37.I2000Clm60BgcCrop.derecho_intel.clm-default
  • Offline check that Σ_j smin_no3_runoff_vr·dz_j equals the mixing-zone NO3 concentration times qflx_surf
  • aux_clm against baselines (not run yet): expect DIFFs in BGC tests with nitrification–denitrification

Questions for reviewers

  • The mixing calculation uses the global zisoi together with the column's col%dz. These match on the standard grids but may not on non-default soil structures. Should that be addressed here or separately?

For the layer straddling depth_runoff_Nloss, the included fraction
(D - z_{j-1})/dz was cancelled by dividing by (D - z_{j-1}), so the layer
lost NO3 as if fully inside the mixing zone. Divide by the full layer
thickness instead, consistent with surface_water.

Fixes ESCOMP#4353

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wwieder

wwieder commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Quicktest results (SBGC-001)

Will ran this fix in an 80 year test against an unmodified baseline (case ctsm5.4.069_audit-easy_f09_BGCcrop_188_quicktest) and asked Claude to:

Create a report that summarizes the key differences in ctsm5.4.069_<label>_f09_BGCcrop_188_quicktest experiments compared to the baseline case, ctsm5.4.069_baseline_f09_BGCcrop_188_quicktest.

All results are in /glade/derecho/scratch/wwieder/archive/*/lnd/hist and should have run for 80 years. Focus the analysis on the last 10 years of each simulation and focus on the changes expected based on the audit made here [audit fix tracker].

Also note if there are likely climate changing differences in LAI, ET, FSH, albedo, net radiation, soil moisture, or runoff. If it's helpful you can use plotting tools available in ~/python/ldf-native-grid-merge-main/.

Below is Claude's summary of the results for this PR.

This fix was tested in the audit-easy run, which bundled DYN-001 (#4343), EMIS-002/003/004 (#4348), SBGC-001 (#4355), LAKE-001 (#4358) and BLD-055/059 (#4341). The changes below are the ones this PR's code can plausibly cause, but they come from the combined run.

Expected: Lower NO3 runoff, since only the mixing-zone fraction of the layer straddling depth_runoff_Nloss now contributes.

Found: NO3 runoff falls −6.3% (5.09 → 4.78 TgN/yr), consistently across regions (about 4–13% lower in each region we looked at). Soil mineral N changes by only +0.1%.

A small N-loss diagnostic and flux correction; no effect on vegetation or the land energy and water budget.

Global land, years 71–80 Baseline Experiment Change % p < 0.05 Units
NO3 runoff (SMIN_NO3_RUNOFF) 5.09 4.78 −0.319 −6.3% yes TgN/yr
NO3 leaching (SMIN_NO3_LEACHED) 0.959 0.970 +0.0106 +1.1% yes TgN/yr
Soil mineral N (SMINN) 1,519 1,521 +1.52 +0.1% yes TgN
Soil NO3 (SMIN_NO3) 1,430 1,431 +1.45 +0.1% yes TgN

Key figures

NO3 runoff
NO3 runoff: experiment minus baseline, years 71–80. Grey cells have no significant change (paired t, p < 0.05); significant over 72% of the plotted land.

Setup

80-year land-only runs: 1850_DATM%CRUJRA2024b_CLM60%BGC-CROP, f09, all started from the same spun-up 1850 restart with identical namelists and CRUJRA forcing (1901–1920 cycled). Each experiment is ctsm5.4.069 plus only its fix commits, compared with an unmodified ctsm5.4.069 baseline over years 71–80. Significance uses a two-sided paired t-test across the 10 annual means (p < 0.05), pairing years that used the same forcing.

Analysis scripts: /glade/u/home/wwieder/audit_quicktest_analysis on GLADE (extract.py, analysis.py). Analysis and write-up prepared with AI assistance (Claude).

@wwieder

wwieder commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor Author

pSASU spin-up results (SBGC-001)

Follow-up to the quicktest results above. Will also ran this fix through a full cold-start spin-up (AD → SASU → pSASU; case ctsm5.4.069_audit_easy_f19_BGCcrop_189_pSASU) alongside an unmodified baseline spin-up (ctsm5.4.069_baseline_f19_BGCcrop_189_pSASU), and asked Claude to:

repeat the analysis from the quicktests posted here [link to the quicktest report] but with the pSASU runs. Focus they analyses on the last 20 years available pSASU resutls and compare each of the test cases with the baseline results.

Below is Claude's summary of the results for this PR.

This fix was spun up in the combined audit_easy case, which bundles DYN-001 (#4343), EMIS-002/003/004 (#4348), SBGC-001 (#4355), LAKE-001 (#4358) and BLD-055/059 (#4341). The changes below are the ones this PR's code can plausibly cause, but they come from the combined run.

Found: NO3 runoff falls 6.0% (4.93 → 4.63 TgN/yr; quicktest −6.3%), by 4–13% in every region we looked at. After the spin-up, ecosystem C in the combined run is 3.34 PgC higher, several times the spin-up noise floor (see Setup below); keeping more N in the soil is a plausible pathway for that.

A small N-loss correction with a small, plausible carbon consequence at equilibrium; no effect on the land energy or water budget.

Global land, pSASU years 221–240 Baseline Experiment Change % Quicktest % p < 0.05 Units
NO3 runoff (SMIN_NO3_RUNOFF) 4.93 4.63 −0.298 −6.0% −6.3% yes TgN/yr
NO3 leaching (SMIN_NO3_LEACHED) 0.957 0.965 +0.00842 +0.9% +1.1% yes TgN/yr
Soil mineral N (SMINN) 1,529 1,534 +4.46 +0.3% +0.1% yes TgN
NPP (NPP) 44.1 44.1 +0.0209 +0.0% +0.0% yes PgC/yr
Soil organic C (TOTSOMC) 2,610 2,613 +3.06 +0.1% +0.0% yes PgC
Total ecosystem C (TOTECOSYSC) 3,368 3,371 +3.34 +0.1% +0.0% yes PgC

Key figures

NO3 runoff
NO3 runoff: experiment minus baseline after the full spin-up, pSASU years 221–240. Grey cells have no significant change (paired t, p < 0.05); significant over 74% of the plotted land.

Setup

Each case is a cold-start spin-up with its fix in place: I1850Clm60BgcCropCrujra, f19_t233, 360 years of accelerated decomposition (AD), 360 years of SASU (hybrid from AD year 361), then 240 years of pSASU (hybrid from SASU year 361, spin-up off). CRUJRA 1901–1920 forcing is cycled with DATM_YR_ALIGN=1, so a given model year has the same forcing in every case. We compare the last 20 pSASU years (221–240) with the same years of the baseline spin-up. Significance is a two-sided paired t-test across the 20 annual means (p < 0.05). Spin-up noise floor: fixes with no plausible carbon pathway (snicar, wf2-accumulator, crop-retrans) end with ecosystem C +0.10 to +0.93 PgC different from the baseline, so treat slow-pool differences of about 1 PgC as noise.

Analysis scripts: /glade/u/home/wwieder/audit_quicktest_analysis on GLADE (extract.py, analysis.py and regional.py run with psasu). Analysis and write-up prepared with AI assistance (Claude).

@wwieder

wwieder commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Implications (SBGC-001)

Short summary of what the full cold-start spin-up (AD → SASU → pSASU, f19 BGC-Crop, 1850) means for this fix.

SBGC-001 (NO3 runoff in the partially-included layer is not scaled by the fraction inside the 5 cm mixing depth): No climate signal. Tested in the audit-easy bundle. NO3 runoff falls 6.0% (4–13% in every region). Ecosystem C in the bundle is 3.3 PgC higher, several times the spin-up noise floor, and this fix keeping more N in the soil is the plausible pathway. Merge as is.

Details: full pSASU results above

Prepared with AI assistance (Claude) from the pSASU analysis in /glade/u/home/wwieder/audit_quicktest_analysis on GLADE.

@wwieder

wwieder commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Test results

Branch 848ce21aa, on Derecho.

Offline check of the mixing-zone identity

I recomputed the nitrification–denitrification surface-runoff loop for master and for this PR, using every active soil and crop column of a spun-up restart.

  • Restart: ctsm5.4.069 f19 BGC-crop, year 241; 14,436 columns.
  • Parameters: sf_no3 = 1.0, depth_runoff_Nloss = 0.05 m.
  • The fraction of each layer above 0.05 m is [1, 0.75, 0, 0, 0].

The check is

Σ_j smin_no3_runoff_vr(j)·dz(j) = qflx_surf · C_mix, where C_mix = sf_no3 · Σ_j f_j·smin_no3_vr(j)·dz(j) / Σ_j f_j·h2osoi_liq(j).

qflx_surf was set small enough that the flux limiters never bind.

Σ runoff / (qflx_surf·C_mix) − 1 Sum of the water weights
master median +25.2%, max +33.3% (5th–95th percentile 12.0%–33.3%) 1.0076 – 1.3324
this PR max |error| 6.7e-16 1 (exact)

On master, the layer that straddles 0.05 m gets a full water weight instead of its fraction above the mixing depth. As a result, NO3 runoff is overstated by up to a third. With this PR the identity holds to round-off.

System tests

I used the f10 grid from the current test list (f10_f10_mt201) instead of mg37.

Test Result
ERP_D_Ld5.f10_f10_mt201.I1850Clm60BgcCrop.derecho_intel.clm-nvmovement--clm-matrixcnOn PASS (COMPARE_base_rest PASS)
ERI_C2_Ld9.f10_f10_mt201.I2000Clm60BgcCrop.derecho_intel.clm-default PASS (COMPARE_branch_hybrid and COMPARE_rest_branch PASS)

These were run on the branch only, without a baseline comparison.

Not run

  • aux_clm against baselines.

Tests set up and run, and this summary written, with AI assistance (Claude Code).

@wwieder
wwieder marked this pull request as ready for review December 3, 2026 14:12
@wwieder

wwieder commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Tests pass and changes in NO3 runoff are relatively small (6%), as expected.

I think this PR is ready for review

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-generated Stuff that was totally AI-generated, at least to start with. investigation Needs to be verified and more investigation into what's going on.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NO3 runoff loss overstated: straddling-layer fraction cancels in the depth_runoff_Nloss mixing calculation

2 participants